package com.example.demo1101.demo1;

public class TestYield {
    public static void main(String[] args) {
        YieldDemo yieldDemo = new YieldDemo();
        YieldDemo yieldDemo1 = new YieldDemo();
        yieldDemo.start();
        yieldDemo1.start();
    }
}

class YieldDemo extends Thread {

    @Override
    public void run() {
        for (int i = 0; i < 20; i++) {
            Thread.yield();
            System.out.println(Thread.currentThread().getName() + "------" + i);
        }
    }

}